package com.example.week11_service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {
    public MyService() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d("My service", "onCreate executed!");
    }

    @Override
    public int onStartCommand(Intent intent,int flags,int startId)
    {
        String msg=intent.getStringExtra("message");
        Log.d("My service","onStartCommand executed!"+ "intent:" +msg+",flags:" + flags + ",startld:"+ startId);
        try {
            Thread.sleep(20000);
        }catch (InterruptedException e)
        {
            e.printStackTrace();
        }
        return super.onStartCommand(intent,flags,startId);
    }
    //stopSelf();
    //stopSelfResult(startId);

    @Override
    public void onDestroy() {
        Log.d("My service","onDestroy executed!");
        super.onDestroy();
    }
    @Override
    public IBinder onBind(Intent intent) {
      return null;
    }
}




